//通讯遮罩-转圈
module utils {
    export class WaitPanel extends eui.Component {
        private waitImgBg: eui.Image
        private waitImg: eui.Image
        constructor() {
            super();
            this.createView();
            this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.destroy, this);
            egret.MainContext.instance.stage.addEventListener(egret.Event.RESIZE, this.modifyBody, this)
        }

        private createView(): void {
            this.width = egret.MainContext.instance.stage.stageWidth;
            this.height = egret.MainContext.instance.stage.stageHeight

            var darkSprite: eui.Rect = new eui.Rect();
            darkSprite.left = 0
            darkSprite.right = 0
            darkSprite.top = 0
            darkSprite.bottom = 0
            darkSprite.fillAlpha = 0.5
            darkSprite.touchEnabled = true;
            this.addChild(darkSprite);

            this.waitImgBg = new eui.Image("loadingBg");
            this.waitImgBg.horizontalCenter = 0
            this.waitImgBg.verticalCenter = 0
            this.addChild(this.waitImgBg);

            this.waitImg = new eui.Image("loadingArrow");
            this.waitImg.horizontalCenter = 0
            this.waitImg.verticalCenter = 0
            this.addChild(this.waitImg);

            EffectUtils.rotationEffect(this.waitImg, 1000);
        }
        private destroy() {
            egret.MainContext.instance.stage.removeEventListener(egret.Event.RESIZE, this.modifyBody, this)
            egret.Tween.removeTweens(this.waitImg)
        }
        public modifyBody() {
            this.width = egret.MainContext.instance.stage.stageWidth;
            this.height = egret.MainContext.instance.stage.stageHeight
        }
    }
}